@echo off
setlocal enabledelayedexpansion

@REM file name
@REM set name=%~n0

@REM param name
set name=%*

@REM enter name
@REM set /p name=Enter keystore name:

set directory=../config
if not exist "!directory!" (
    mkdir "!directory!"
)

@REM 30 years
keytool -genkeypair -keyalg RSA -keysize 2048 -validity 10950 ^
    -dname "CN=!name!,OU=!name!,O=!name!" ^
    -keystore !directory!/!name!.jks ^
    -storepass !name! ^
    -alias !name! ^
    -keypass !name! || exit /b 0

(
    echo storeFile=!directory!/!name!.jks
    echo storePassword=!name!
    echo keyAlias=!name!
    echo keyPassword=!name!
) > !directory!/key.properties

endlocal
